package com.example.smartcity.ui.person.Adapter

import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.TextView
import androidx.recyclerview.widget.RecyclerView
import com.example.smartcity.R
import com.example.smartcity.ui.person.model.FeedEntity

/**
 *
 *  ANDROID STUDIO -version 2022.19
 *  项目名: FeedBackRecyclerViewAdapter
 *  创建时间: 2023/2/14 22:23
 *  CodeAuthor: ikun
 *  email: 2506789532@qq.com
 **/
class FeedBackRecyclerViewAdapter(val data: List<FeedEntity>) : RecyclerView.Adapter<FeedBackRecyclerViewAdapter.ViewHolder>(){
    inner class ViewHolder(view: View) : RecyclerView.ViewHolder(view){
        // 获取控件
        val title = view.findViewById<TextView>(R.id.feedbackReTitle)
        val contend = view.findViewById<TextView>(R.id.feedbackReContend)
        val date = view.findViewById<TextView>(R.id.feedbackReDate)
    }

    override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder {
        val root = LayoutInflater.from(parent.context).inflate(R.layout.recyclerview_feedback_item, parent, false)
        return ViewHolder(root)
    }

    override fun getItemCount() = data.size

    override fun onBindViewHolder(holder: ViewHolder, position: Int) {
        // 填充数据
        val listData = data[position]
        holder.title.text = listData.title1
        holder.contend.text = listData.contend1
        holder.date.text = listData.createTime

    }
}